package buber.data;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;


import buber.exceptions.BadDataException;
import buber.util.Const;

public class DataRow {
	private List<DataCell> cells;
	public DataRow(){
		cells=new ArrayList<DataCell>();
	}
	public DataRow(String row) throws BadDataException{
		cells=new ArrayList<DataCell>();
		StringTokenizer st=new StringTokenizer(row,Const.COL_SEPARATOR);
		while(st.hasMoreTokens()){
			cells.add(new DataCell(st.nextToken()));
		}
	}
	public List<DataCell> getCells() {
		return cells;
	}

	public void setCells(List<DataCell> cells) {
		this.cells = cells;
	}
	public DataCell[] asCellArray(){
		DataCell[] array = new DataCell[cells.size()];
		for(int i=0;i<cells.size();i++){
			array[i]=cells.get(i);
		}
		return array;
	}
	public int getSize(){
		return cells.size();
	}
	public void addCell(DataCell cell){
		cells.add(cell);
	}
}
